package org.omg.CORBA;

import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;


public class ClienteCorba {

	public static void main(String[] args) {

		try {

			// Cria e inicializa o ORB
			ORB orb = ORB.init(args, null);

			// Obtem referencia para o servico de nomes
			Object objRef = orb.resolve_initial_references("NameService");
			NamingContextExt nameContextExt = NamingContextExtHelper
					.narrow(objRef);

			// Obtem referencia para o servidor
			String nomeServidor = "Sensor";
			Sensor sensor = SensorHelper.narrow(nameContextExt
					.resolve_str(nomeServidor));

			System.out.println(sensor.historicoViagens());

		} catch (Exception erro) {
			System.err.println("Erro " + erro.getMessage());
		}
	}
}

